package com.example.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyReceiver extends BroadcastReceiver {
    private static final String TAG = "MyReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e(TAG,"onReceive");
        String action = intent.getAction();
        if(action.equals("WEATHER_REPORT")){
            String city = intent.getStringExtra("CITY");
            String weather = intent.getStringExtra("WEATHER");
            int high = intent.getIntExtra("HIGH",0);
            Log.e(TAG,city+weather+high);
        }else if(action.equals("NEWS_REPORT")){
            String title = intent.getStringExtra("TITLE");
            String time = intent.getStringExtra("TIME");
            String addr = intent.getStringExtra("ADDR");
            Log.e(TAG,title+time+addr);
        }
    }
}